<ul class="layui-nav layui-nav-tree" id="leftContent" lay-filter="">
  <li class="layui-nav-item layui-nav-itemed">
    <a class="" href="javascript:;"><?php echo lang('menu_content');?></a>
  </li>
  <div id="cateTree" class="dtree" data-id="0"></div>
</ul>
<script>
  layui.use(["dtree", "layer", "jquery"], function () {
    var dtree = layui.dtree,
      layer = layui.layer,
      $ = layui.jquery;

    dtree.render({
      elem: "#cateTree",
      url: "<{caUrl('contentcate','index')}>&mod=1&list_json", // 使用url加载（可与data加载同时存在）
      dataStyle: "layuiStyle", //使用layui风格的数据格式
      //dataFormat: "list",  //配置data的风格为list
      response: { message: "msg", statusCode: 0 }, //修改response中返回数据的定义
      //checkbar:true,
      icon: "2", //修改二级图标样式
      initLevel: "3", //默认展开层级为1
      //,accordion: true  // 开启手风琴
    });

    // 绑定节点点击
    dtree.on("node('cateTree')", function (obj) {
      if (obj.param.leaf) {
        loadMain('<{caUrl("content","index")}>&menuname=' + obj.param.context + '&cid=' + obj.param.nodeId);
      } else {
        var $div = obj.dom;
        cateTree.clickSpread($div); //调用内置函数展开节点
      }
    });
  });
</script>
